package com.hzhq.contract.convert;

import com.hzhq.contract.bean.dto.RoleDTO;
import com.hzhq.contract.bean.entity.Role;
import com.hzhq.contract.bean.vo.RoleVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author: hzhq1255
 * @mail: hzhq1255@163.com
 * @date: 2021/4/15 20:18
 * @desc:
 */
@Mapper
public interface RoleConvertBasic {

    RoleConvertBasic INSTANCE = Mappers.getMapper(RoleConvertBasic.class);


    RoleDTO poToDto(Role source);

    Role dtoToPo(RoleDTO source);

    @Mappings({
            @Mapping(target = "roleId", expression = "java(com.hzhq.contract.util.ConvertUtil.objectIdToString(source.getRoleId()))")
    })
    RoleVO dtoToVo(RoleDTO source);

    @Mappings(value = {
            @Mapping(target = "roleId", expression = "java( com.hzhq.contract.util.ConvertUtil.stringToObjectId(source.getRoleId()))"),
            @Mapping(target = "deleted", expression = "java(com.hzhq.contract.status.DefaultValue.NOT_DELETED)")
    })
    RoleDTO voToDto(RoleVO source);

}
